#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

bool isPalindrome(int x) {
    if(x < 0)
        return false;
    int total = 0;
    int xx = x;         //备份 x
    while(x > 0) {
        total++;
        x /= 10;
    }
    printf("total is : %d \n", total);

    int *nums = malloc(total * sizeof(int));
    int index = 0;
    x = xx;
    while(x > 0) {
        nums[index] = x % 10;
        x /= 10;
        index++;
    } 

    printf("----- nums is ------ ");
    for(int i = 0; i < total; i++)
        printf(" %d ", nums[i]);

    printf("\n");

    int begin = 0; 
    int end = total - 1;
    while (end - begin > 0){
        if(nums[begin++] != nums[end--])
            return false;
    }
    return true;
}

int main() {
    printf("Is Palindrome number? --- %s \n", isPalindrome(121) ? "true" : "false");
    return 0;
}